package main

import (
	"fmt"
	gotdsbmi "github.com/armstrongli/go-bmi"
)

func main() {
	//提示要求
	intPeopleNum := giveUserTip()
	floatTotalBodyFat := 0.0 //初始化总体脂率为0
	for i := 0; i < intPeopleNum; i++ {
		name, age, sexVal, weight, tall := GetUserInfo()
		bmi, err := gotdsbmi.BMI(weight, tall)
		if err != nil {
			fmt.Println(err)
		}
		//使用自己的fateRate的计算
		//fateRate := CalcFateRate(bmi, age, sexVal)
		//扩展老师包中的计算
		fateRate := gotdsbmi.CalcFateRate(bmi, age, sexVal)
		suggestions := GetSuggestions(fateRate, sexVal, age)
		fmt.Printf("姓名:%s的bmi是:%f,体脂率是:%f,给你的建议是:%s\n", name, bmi, fateRate, suggestions)
		floatTotalBodyFat += fateRate
	}
	fmt.Printf("总共输入%d人的信息，%d人的体脂率平均值为:%f", intPeopleNum, intPeopleNum, floatTotalBodyFat/float64(intPeopleNum))
}

func giveUserTip() int {
	intPeopleNum := 0
	fmt.Println("请输入要录入的人数")
	fmt.Scanln(&intPeopleNum)
	return intPeopleNum
}
